import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:life_service/color/hex.dart';
import 'package:life_service/route/index.dart';

void main() {
  SystemChrome.setSystemUIOverlayStyle(
    const SystemUiOverlayStyle(
      statusBarIconBrightness: Brightness.light,
      statusBarColor: Colors.transparent,
    ),
  );
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MediaQuery.removeViewPadding(
      context: context,
      removeBottom: true,
      removeLeft: true,
      removeRight: true,
      removeTop: false,
      child: ScreenUtilInit(
        designSize: const Size(375, 667),
        minTextAdapt: true,
        splitScreenMode: true,
        builder: (_, child) {
          return GetMaterialApp(
            debugShowCheckedModeBanner: false,
            title: '生活服务',
            theme: ThemeData(
              primarySwatch: Colors.blue,
              textTheme: Typography.englishLike2018.apply(fontSizeFactor: 1.sp),
              useMaterial3: true,
              colorScheme: ColorScheme.fromSeed(
                seedColor: Colors.deepPurple,
                primary: HexColor(HexColor.colorFf62),
                secondary: HexColor(HexColor.color666e),
              ),
              appBarTheme: AppBarTheme(
                systemOverlayStyle: SystemUiOverlayStyle.dark,
                centerTitle: true,
                titleSpacing: 0,
                titleTextStyle: TextStyle(
                  fontFamily: 'Medium',
                  fontSize: 20.sp,
                  color: HexColor(HexColor.color3333),
                ),
                elevation: 0,
                surfaceTintColor: Colors.transparent,
              ),
              primaryColor: HexColor(HexColor.colorFf62),
            ),
            darkTheme: ThemeData(
              brightness: Brightness.dark,
              useMaterial3: true,
            ),
            initialRoute: Routes.home,
            getPages: Routes.pages,
            transitionDuration: const Duration(milliseconds: 500),
            defaultTransition: Transition.cupertino,
            localizationsDelegates: const [
              GlobalMaterialLocalizations.delegate,
              GlobalWidgetsLocalizations.delegate,
              GlobalCupertinoLocalizations.delegate,
            ],
            // supportedLocales: const [Locale('zh', 'CH'), Locale('en', 'US')],
            // locale: const Locale('zh', 'CH'),
          );
        },
      ),
    );
  }
}
